/************************************************************************
Arise Engine		Helper.h

					E-mail:	arise_engine@mail.ru

created:			10.02.2007
last changes:		25.01.2008
************************************************************************/
#pragma once


HRESULT WINAPI Trace( const CHAR* strFile, DWORD dwLine, HRESULT hr, const char* strMsg);
void Trace(const CHAR* strFile, DWORD dwLine, const char* strMsg);

//	dx sdk helper macroses

#define V(x)					{ HRESULT hr = x; if( FAILED(hr) ) { Trace( __FILE__, (DWORD)__LINE__, hr, "FAILED" ); } }
#define P(x)					{ if( x < 0 ) { Trace( __FILE__, (DWORD)__LINE__, "FAILED" ); } }
#define V_RETURN_EX(x)			{ HRESULT hr = x; if( FAILED(hr) ) { return Trace( __FILE__, (DWORD)__LINE__, hr, "FAILED" ); } }
#define V_RETURN(x)				{ HRESULT hr = x; if( FAILED(hr) ) { return hr; } }

#define SAFE_DELETE(p)			{ if(p) { delete (p);     (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p)	{ if(p) { delete[] (p);   (p)=NULL; } }   
#define SAFE_RELEASE(p)			{ if(p) { (p)->Release(); (p)=NULL; } }
